package cn.woblog.recyclerviewsample;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

/**
 * Created by renpingqing on 2017/4/4.
 */

public class ItemAnimationAdapter extends
    BaseRecyclerViewAdapter<String, ItemAnimationAdapter.ViewHolder> {

  public ItemAnimationAdapter(Context context) {
    super(context);
  }

  @Override
  public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    return new ViewHolder(getInflater().inflate(R.layout.simple_list_item_3, parent, false));
  }

  @Override
  public void onBindViewHolder(ViewHolder holder, int position) {
    super.onBindViewHolder(holder, position);
    holder.bindData(getData(position));
  }

  class ViewHolder extends BaseRecyclerViewAdapter.ViewHolder
//    implements AnimateViewHolder
  {

    private final TextView tv;

    public ViewHolder(View itemView) {
      super(itemView);
      tv = (TextView) itemView.findViewById(android.R.id.text1);
    }

    public void bindData(String data) {
      tv.setText(data);
    }

//  @Override
//  public void preAnimateRemoveImpl(RecyclerView.ViewHolder holder) {
//
//  }
//
//  @Override
//  public void animateRemoveImpl(RecyclerView.ViewHolder holder, ViewPropertyAnimatorListener listener) {
//    ViewCompat.animate(itemView)
//        .translationY(-itemView.getHeight() * 0.3f)
//        .alpha(0)
//        .setDuration(300)
//        .setListener(listener)
//        .start();
//  }
//
//  @Override
//  public void preAnimateAddImpl(RecyclerView.ViewHolder holder) {
//    ViewCompat.setTranslationY(itemView, -itemView.getHeight() * 0.3f);
//    ViewCompat.setAlpha(itemView, 0);
//  }
//
//  @Override
//  public void animateAddImpl(RecyclerView.ViewHolder holder, ViewPropertyAnimatorListener listener) {
//    ViewCompat.animate(itemView)
//        .translationY(0)
//        .alpha(1)
//        .setDuration(300)
//        .setListener(listener)
//        .start();
//  }
  }
}
